package com.hanbang.chu_xing_gao_zhao.view_find;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.LocationClientOption.LocationMode;
import com.baidu.mapapi.SDKInitializer;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdate;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.Marker;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.map.TextOptions;
import com.baidu.mapapi.model.LatLng;
import com.hanbang.chu_xing_gao_zhao.application.HttpInterfaces;
import com.hanbang.chu_xing_gao_zhao.entity.PopupData;
import com.hanbang.chu_xing_gao_zhao.entity.ZouWeiRenData;
import com.hanbang.chu_xing_gao_zhao.myview.HorizontalDividerItemDecoration;
import com.hanbang.chu_xing_gao_zhao.myview.MorePopupWindowPublic_B;
import com.hanbang.chu_xing_gao_zhao.utils.BitmapUtil;
import com.hanbang.chu_xing_gao_zhao.utils.JsonHelper;
import com.hanbang.chu_xing_gao_zhao.utils.MyRequestCallBack;
import com.hanbang.chu_xing_gao_zhao.utils.MyToast;
import com.hanbang.chu_xing_gao_zhao.utils.StringUtils;
import com.hanbang.chu_xing_gao_zhao.utils.SystemTools;
import com.hanbang.chu_xing_gao_zhao.view_city_select.ItemCityData;
import com.hanbang.chu_xing_gao_zhao.view_dynamic.DynamicManageHome;
import com.hanbang.cxgz_2.R;
import com.lidroid.xutils.db.sqlite.Selector;
import com.lidroid.xutils.exception.DbException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.client.HttpRequest;

import org.json.JSONObject;

import java.util.ArrayList;

public class FindNearbyMapFragment extends Fragment {

    /**
     * 数据集  地图的
     */
    private ArrayList<ZouWeiRenData> listData = new ArrayList<>();

    /**
     * 数据集  列表的
     */
    private ArrayList<ZouWeiRenData> listDataList = null;

    /**
     * 当前筛选的标识
     */
    private int shaixuanFlag = 1;
    /**
     * 底部导航按钮-发现
     */
    private LinearLayout find;


    private LinearLayout saixuan;

    /**
     * 定义文字所显示的坐标点
     */
    LatLng locationResult;

    /**
     * 显示地图控件
     */
    private MapView mMapView = null;

    /**
     * 百度地图
     */
    private BaiduMap mBaiduMap = null;

    /**
     * 类是定位SDK的核心类
     */
    public LocationClient mLocationClient = null;

    /**
     * 接口有1个方法需要实现： 1.接收异步返回的定位结果，参数是BDLocation类型参数。
     */
    public BDLocationListener myListener = new MyLocationListener();
    private RecyclerView recyclerView;
    public String myLocation = "";

    private FindMainFragmentActivity findMainFragmentActivity;
    private View view;
    private View bottonView;
    private View dingweiView;
    /**
     * 设置地图的层级
     */
    private float mapZoom = 16.0f;
    //4个图片对象
    private BitmapDescriptor cs;
    private BitmapDescriptor cs_vip;
    private BitmapDescriptor jjr;
    private BitmapDescriptor jjr_vip;

    private MyAdapter adapter = null;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        findMainFragmentActivity = (FindMainFragmentActivity) getActivity();

        // 在使用SDK各组件之前初始化context信息，传入ApplicationContext
        // 注意该方法要再setContentView方法之前实现
        SDKInitializer.initialize(findMainFragmentActivity.getApplicationContext());
        cs = BitmapDescriptorFactory.fromBitmap(BitmapUtil.decodeResource(findMainFragmentActivity, R.drawable.chushi, SystemTools.dip2px(findMainFragmentActivity, 45), SystemTools.dip2px(findMainFragmentActivity, 45)));
        cs_vip = BitmapDescriptorFactory.fromBitmap(BitmapUtil.decodeResource(findMainFragmentActivity, R.drawable.chushi_vip, SystemTools.dip2px(findMainFragmentActivity, 45), SystemTools.dip2px(findMainFragmentActivity, 45)));
        jjr = BitmapDescriptorFactory.fromBitmap(BitmapUtil.decodeResource(findMainFragmentActivity, R.drawable.jjr, SystemTools.dip2px(findMainFragmentActivity, 45), SystemTools.dip2px(findMainFragmentActivity, 45)));
        jjr_vip = BitmapDescriptorFactory.fromBitmap(BitmapUtil.decodeResource(findMainFragmentActivity, R.drawable.jjr_vip, SystemTools.dip2px(findMainFragmentActivity, 45), SystemTools.dip2px(findMainFragmentActivity, 45)));
        view = inflater.inflate(R.layout.find_nearby_map, null);
        initView();
        initLocation();

        return view;
    }


    public FindNearbyMapFragment() {

    }

    /**
     * /** 初始化view
     */
    private void initView() {
        // 获取地图控件引用
        mMapView = (MapView) view.findViewById(R.id.bmapView);
        mMapView.showZoomControls(false);
        mBaiduMap = mMapView.getMap();
        mBaiduMap.setOnMarkerClickListener(markerClickListener);
        mLocationClient = new LocationClient(getActivity()); // 声明LocationClient类
        mLocationClient.registerLocationListener(myListener); // 注册监听函数

        find = (LinearLayout) view.findViewById(R.id.bar_botton_bar_find);


//        titleViewAndAddLinstener((TextView) view.findViewById(R.id.tv_bar_top_conver_classify_title3));
/**
 * 地图筛选
 *
 * @param view
 */
        saixuan = (LinearLayout) view.findViewById(R.id.shaixuan);
        saixuan.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(final View v) {
                ArrayList<PopupData> arrayList = new ArrayList<PopupData>();
                arrayList.add(new PopupData(1, "全部", 0, null));
                arrayList.add(new PopupData(2, "厨师", 0, null));
                arrayList.add(new PopupData(3, "经理人", 0, null));
                MorePopupWindowPublic_B popup = new MorePopupWindowPublic_B(getActivity(), arrayList, 3, 300);
                popup.showPopupWindow(v, 1);
                popup.setOnClickCallback(new MorePopupWindowPublic_B.OnClickCallback() {
                    @Override
                    public void onClick(MorePopupWindowPublic_B morePopWindow, int id, String content, int type) {
                        shaixuanFlag = id;
                        upMapMarkerInfo(id);
                        ((TextView) ((ViewGroup) v).getChildAt(0)).setText(content);
                        if (recyclerView.getVisibility() == View.VISIBLE && listDataList != null) {

                            if (id == 1) {
                                if (listDataList.size() != listData.size()) {
                                    listDataList = new ArrayList<ZouWeiRenData>(listData);
                                    adapter.notifyDataSetChanged();
                                }
                            } else if (id == 2) {
                                listDataList.clear();
                                for (ZouWeiRenData data : listData) {
                                    if (data.getGroup_id() == 1) {
                                        listDataList.add(data);
                                    }
                                }
                                adapter.notifyDataSetChanged();

                            } else if (id == 3) {
                                listDataList.clear();
                                for (ZouWeiRenData data : listData) {
                                    if (data.getGroup_id() == 2) {
                                        listDataList.add(data);
                                    }
                                }
                                adapter.notifyDataSetChanged();
                            }
                        }
                    }
                });
            }
        });

        /**
         * 定位按钮
         */

        dingweiView = view.findViewById(R.id.dingwei);
        dingweiView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dingweiView.setEnabled(false);
                mLocationClient.requestLocation();
                v.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        dingweiView.setEnabled(true);
                    }
                }, 1000);
            }
        });

        recyclerView = (RecyclerView) view.findViewById(R.id.swipe_target);
        recyclerView.setItemAnimator(new DefaultItemAnimator());
        recyclerView.addItemDecoration(new HorizontalDividerItemDecoration.Builder(findMainFragmentActivity).color(getResources().getColor(R.color.gray_ee)).
                size(SystemTools.dip2px(findMainFragmentActivity, 10f)).build());
        recyclerView.setLayoutManager(new LinearLayoutManager(findMainFragmentActivity));

        /**
         * 地图与列表的切换
         */
        view.findViewById(R.id.qiehuan).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LinearLayout ll = (LinearLayout) v;
                //列表模式
                if (recyclerView.getVisibility() == View.VISIBLE) {
                    //切换为地图模式
                    startModel(1, ll);
                    //地图模式
                } else {
                    startModel(2, ll);
                }
            }
        });

    }

    /**
     * 启动模式
     *
     * @param type 1为地图，2为列表
     */
    private void startModel(int type, LinearLayout ll) {
        if (type == 1) {
            adapter = null;
            recyclerView.setVisibility(View.GONE);
            ((ImageView) ll.getChildAt(0)).setImageResource(R.drawable.list);
            ((TextView) ll.getChildAt(1)).setText("列表模式");
            view.findViewById(R.id.top_button).setBackgroundColor(getResources().getColor(R.color.translucent));
            listDataList = null;
            recyclerView.setAdapter(null);
        } else if (type == 2) {
            listDataList = new ArrayList<ZouWeiRenData>(listData);
            adapter = new MyAdapter();
            recyclerView.setAdapter(adapter);
            recyclerView.setVisibility(View.VISIBLE);
            ((ImageView) ll.getChildAt(0)).setImageResource(R.drawable.map);
            ((TextView) ll.getChildAt(1)).setText("地图模式");
            view.findViewById(R.id.top_button).setBackgroundColor(getResources().getColor(R.color.white));
        }
    }


    @Override
    public void onDestroy() {
        // 退出时销毁定位
        mLocationClient.stop();
        mLocationClient.unRegisterLocationListener(myListener);// 销毁监听，如果不销毁在退出是会报空指针异常
        // 关闭定位图层
        mBaiduMap.setMyLocationEnabled(false);
        mMapView.onDestroy();
        mMapView = null;
        cs.recycle();
        cs_vip.recycle();
        jjr.recycle();
        jjr_vip.recycle();
        super.onDestroy();
    }

    @Override
    public void onResume() {
        super.onResume();
//         在activity执行onResume时执行mMapView. onResume ()，实现地图生命周期管理
        if (locationResult == null && !mLocationClient.isStarted()) {
            mLocationClient.start();
        }
        mMapView.onResume();
    }


    @Override
    public void onPause() {
        super.onPause();
        mLocationClient.stop();
        // 在activity执行onPause时执行mMapView. onPause ()，实现地图生命周期管理
        mMapView.onPause();
    }

    public static enum Mode {
        MAP_TYPE_NORMAL, MAP_TYPE_SATELLITE;
    }

    /**
     * 设置定位参数包括：定位模式（高精度定位模式，低功耗定位模式和仅用设备定位模式），返回坐标类型，是否打开GPS，是否返回地址信息、位置语义化信息、
     * POI信息等等。
     */
    private void initLocation() {
        mBaiduMap.setMyLocationEnabled(true);
        LocationClientOption option = new LocationClientOption();
        option.setLocationMode(LocationMode.Hight_Accuracy);// 可选，默认高精度，设置定位模式，高精度，低功耗，仅设备
        option.setCoorType("bd09ll");// 可选，默认gcj02，设置返回的定位结果坐标系
        option.setScanSpan(0);// 可选，默认0，即仅定位一次，设置发起定位请求的间隔需要大于等于1000ms才是有效的
        option.setIsNeedAddress(true);// 可选，设置是否需要地址信息，默认不需要
        option.setOpenGps(true);// 可选，默认false,设置是否使用gps
        option.setLocationNotify(false);// 可选，默认false，设置是否当gps有效时按照1S1次频率输出GPS结果
        option.setIsNeedLocationDescribe(false);// 可选，默认false，设置是否需要位置语义化结果，可以在BDLocation.getLocationDescribe里得到，结果类似于“在北京天安门附近”
        option.setIsNeedLocationPoiList(true);// 可选，默认false，设置是否需要POI结果，可以在BDLocation.getPoiList里得到
        option.setIgnoreKillProcess(false);// 可选，默认false，定位SDK内部是一个SERVICE，并放到了独立进程，设置是否在stop的时候杀死这个进程，默认杀死
        option.SetIgnoreCacheException(false);// 可选，默认false，设置是否收集CRASH信息，默认收集
        option.setEnableSimulateGps(false);// 可选，默认false，设置是否需要过滤gps仿真结果，默认需要
        mLocationClient.setLocOption(option);
        mLocationClient.start();
    }

    /**
     * @param location
     * @return
     */
    private String getLocation(String location) {

        mMapView.onResume();
        location = myLocation;
        mMapView.onPause();
        return location;
    }

    //地图 Marker 覆盖物点击事件监听接口
    BaiduMap.OnMarkerClickListener markerClickListener = new BaiduMap.OnMarkerClickListener() {

        @Override
        public boolean onMarkerClick(Marker marker) {

            /**
             * 获取数据
             */
            for (ZouWeiRenData data : listData) {
                if (data.getNum() == marker.getZIndex()) {
                    if (bottonView == null) {
                        bottonView = findMainFragmentActivity.getLayoutInflater().inflate(R.layout.find_nearby_map_button, null);
                        bottonView.setId(R.id.id1);
                        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                        params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                        ((ViewGroup) view.findViewById(R.id.map_rl)).addView(bottonView, params);
                        RelativeLayout.LayoutParams paramsD = (RelativeLayout.LayoutParams) dingweiView.getLayoutParams();
                        paramsD.addRule(RelativeLayout.ABOVE, R.id.id1);
                        paramsD.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0);
                    }
                    setButtonView(data);
                    break;
                }
            }

            return false;
        }
    };

    /**
     * 对底部VIew 的设置
     */
    private void setButtonView(final ZouWeiRenData data) {

        if (bottonView == null || data == null) return;

        bottonView.findViewById(R.id.delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View vv) {
                ((ViewGroup) view.findViewById(R.id.map_rl)).removeView(bottonView);
                ((RelativeLayout.LayoutParams) dingweiView.getLayoutParams()).addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
                bottonView = null;
            }
        });
        bottonView.findViewById(R.id.jrgrgzs).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View vv) {
                //进入个人工作室
                toGeRenZhuYe(data);
            }
        });


        findMainFragmentActivity.bitmapUtils.display(bottonView.findViewById(R.id.touxiang), SystemTools.getHttpFileUrl(data.getAvatar()));

        if (data.is_vip()) {
            bottonView.findViewById(R.id.huiyuan).setVisibility(View.VISIBLE);
        } else {
            bottonView.findViewById(R.id.huiyuan).setVisibility(View.GONE);
        }
        ((TextView) bottonView.findViewById(R.id.name)).setText(StringUtils.isNullToConvert(data.getUser_name(), ""));
        if (data.getGroup_id() == 1) {
            String shanchang = "擅长 : ";
            ((TextView) bottonView.findViewById(R.id.zw_sc)).setText(shanchang + StringUtils.isNullToConvert(data.getCuisinesName(), ""));
        } else if (data.getGroup_id() == 2) {
            ((TextView) bottonView.findViewById(R.id.zw_sc)).setText(StringUtils.isNullToConvert(data.getZhiwei(), ""));
        }
        ((TextView) bottonView.findViewById(R.id.fenshi)).setText("粉丝 : " + data.getLikecount());
        ((TextView) bottonView.findViewById(R.id.miji)).setText("秘籍 : " + data.getKetangcount());


    }

    public class MyLocationListener implements BDLocationListener {

        @Override
        public void onReceiveLocation(BDLocation location) {

            // map view 销毁后不在处理新接收的位置
            if (location == null || mMapView == null || location == null) {
                return;
            }
            locationResult = new LatLng(location.getLatitude(), location.getLongitude());
            myLocation = location.getProvince() + "-" + location.getCity() + "-" + location.getDistrict() + "-"
                    + location.getStreet();
            MyLocationData locData = new MyLocationData.Builder()
                    .accuracy(0)
                            // 此处设置开发者获取到的方向信息，顺时针0-360
                    .direction(location.getDirection()).latitude(location.getLatitude())
                    .longitude(location.getLongitude()).build();
            mBaiduMap.setMyLocationData(locData);
            MapStatus.Builder builder = new MapStatus.Builder();
            builder.target(locationResult).zoom(mapZoom);
            mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));

            int cityid = getCityList(location.getCity().replaceAll(" ", ""));
            if (cityid != -1) {
                getHttpList(cityid, locationResult);
            } else {
                MyToast.show(findMainFragmentActivity, "此城市不存在", 1);
            }


        }
    }

    /**
     * 根据数据集更新地图图标
     *
     * @param type 1:全部  2：厨师 3：经纪人
     */
    private void upMapMarkerInfo(int type) {
        if (listData != null) {
            mBaiduMap.clear();
            for (ZouWeiRenData data : listData) {
                MarkerOptions marker = new MarkerOptions();
                //经纬度
                String[] loc = data.getGps().split(",");
                try {
                    marker.position(new LatLng(Double.valueOf(loc[1]), Double.valueOf(loc[0])));
                } catch (NumberFormatException e) {
                    break;
                }
                marker.zIndex(data.getNum());
                if (data.getGroup_id() == 1) {
                    if (type == 3) {
                        break;
                    }
                    if (data.is_vip()) {
                        marker.icon(cs_vip);
                    } else {
                        marker.icon(cs);
                    }
                } else if (data.getGroup_id() == 2) {
                    if (type == 2) {
                        break;
                    }
                    if (data.is_vip()) {
                        marker.icon(jjr_vip);
                    } else {
                        marker.icon(jjr);
                    }
                } else {
                    break;
                }
                mBaiduMap.addOverlay(marker);
            }
        }
    }

    private int getCityList(String city) {
        try {
            ItemCityData list = findMainFragmentActivity.dbUtils.findFirst(Selector.from(ItemCityData.class).where("CityName", "=", city));
            if (list != null) {
                return list.getCityID();
            }
        } catch (DbException e) {
            e.printStackTrace();
        }
        return -1;
    }

    /**
     * 显示文字
     *
     * @param name ：文字内容
     */
    private void setName(String name, LatLng llText) {
        // 构建文字Option对象，用于在地图上添加文字
        if (name != null) {

            OverlayOptions textOption = new TextOptions().bgColor(0xAAFFFF00).fontSize(24).fontColor(0xFFFF00FF)
                    .text(name).rotate(0).position(llText);
            // 在地图上添加该文字对象并显示
            mBaiduMap.addOverlay(textOption);
        }
    }

    /**
     * 设置显示地图的类型
     *
     * @param type
     */
    private void setMapTepy(String type) {
        if (type.equals("MAP_TYPE_NORMAL")) {
            // 普通地图
            mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
        } else {
            // 卫星地图
            mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
        }

    }

    /**
     * 设置当前位置,让地图显示定位所在位置
     */
    private void setMapLocation(LatLng latLng) {
        MapStatus.Builder status = new MapStatus.Builder();
        status.target(latLng).zoom(mapZoom);
        MapStatusUpdate m = MapStatusUpdateFactory.newMapStatus(status.build());
        mBaiduMap.animateMapStatus(m);
    }

    /**
     * 设置地图的定位图标,
     *
     * @param descriptor : 定位图标   未空时显示默认图标
     */
    private void setMapLocationIcon(BitmapDescriptor descriptor) {
        mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
                MyLocationConfiguration.LocationMode.NORMAL, true, descriptor));
    }

    /**
     * 获取网络列表
     */
    private void getHttpList(int cityID, LatLng latLng) {
        if (locationResult != null) {
            RequestParams params = new RequestParams();
            params.addBodyParameter("action", "GetNearMember");
            params.addBodyParameter("cityID", String.valueOf(cityID));
            params.addBodyParameter("gps", latLng.longitude + "," + latLng.latitude);
            findMainFragmentActivity.httpUtils.send(HttpRequest.HttpMethod.POST, HttpInterfaces.ORG_POST, params, new MyRequestCallBack<String>(getActivity(), "加载中...") {
                @Override
                public void onSuccess(ResponseInfo<String> responseInfo) {
                    super.onSuccess(responseInfo);
                    try {
                        JSONObject json = new JSONObject(responseInfo.result);
                        int result = json.getInt("Result");
                        if (result == 0) {
                            listData.clear();
                            listData.addAll(JsonHelper.parseCollection(json.getJSONArray("list"), ArrayList.class, ZouWeiRenData.class));
                            upMapMarkerInfo(shaixuanFlag);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        } else {

        }
    }


    class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {


        @Override
        public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

            return new MyViewHolder(LayoutInflater.from(
                    findMainFragmentActivity).inflate(R.layout.find_nearby_map_listitem, parent,
                    false));
        }

        @Override
        public void onBindViewHolder(MyViewHolder holder, int position) {
            ZouWeiRenData data = listDataList.get(position);
            findMainFragmentActivity.bitmapUtils.display(holder.touxiang, SystemTools.getHttpFileUrl(data.getAvatar()));

            if (data.is_vip()) {
                holder.vipTag.setVisibility(View.VISIBLE);
            } else {
                holder.vipTag.setVisibility(View.GONE);
            }
            holder.name.setText(StringUtils.isNullToConvert(data.getUser_name(), ""));
            if (data.getGroup_id() == 1) {
                String shanchang = "擅长 : ";
                holder.zw_sc.setText(shanchang + StringUtils.isNullToConvert(data.getCuisinesName(), ""));
            } else if (data.getGroup_id() == 2) {
                holder.zw_sc.setText(StringUtils.isNullToConvert(data.getZhiwei(), ""));
            }
            holder.fenshi.setText("粉丝 : " + data.getLikecount());
            holder.miji.setText("秘籍 : " + data.getKetangcount());
            holder.juli.setText("距离  " + StringUtils.roundString(data.getKm(), 2) + "km");

        }

        @Override
        public int getItemCount() {
            return listDataList.size();
        }

        class MyViewHolder extends RecyclerView.ViewHolder {
            TextView name;
            TextView juli;
            TextView zw_sc;
            TextView fenshi;
            TextView miji;
            ImageView touxiang;
            ImageView vipTag;

            public MyViewHolder(View view) {
                super(view);
                name = (TextView) view.findViewById(R.id.name);
                juli = (TextView) view.findViewById(R.id.juli);
                zw_sc = (TextView) view.findViewById(R.id.zw_sc);
                fenshi = (TextView) view.findViewById(R.id.fenshi);
                miji = (TextView) view.findViewById(R.id.miji);
                touxiang = (ImageView) view.findViewById(R.id.touxiang);
                vipTag = (ImageView) view.findViewById(R.id.huiyuan);

                view.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        //进入个人工作室
                        toGeRenZhuYe(listDataList.get(getAdapterPosition()));
                    }
                });
            }
        }
    }

    //进入个人工作室
    private void toGeRenZhuYe(ZouWeiRenData data) {
        Intent intent = new Intent(findMainFragmentActivity, DynamicManageHome.class);
        intent.putExtra("id", data.getUser_id());
        findMainFragmentActivity.startActivity(intent);
    }
}
